/*正解得用数论找规律
摆了，就这样吧*/

#include <iostream>
#include <cstring>

using namespace std;

const int db[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string ans;	
string tmp;
//bool flag = true;

bool smaller(string a, string b){
	if(a.size() < b.size()){
		return true;
	}else if (a.size() == b.size()){
		for(int i = 0; i < a.size(); i++){
			if ((a[i] - '0') < b[i] - '0'){
				return true;
			}
		}
	}
	return false;
}

void dfs(int n){
	if(tmp[0] == '0' || ans[0] == '0') return; 
    if(n == 0){
		if (smaller(tmp, ans)){
			ans = tmp;
		}
		return;
	}
    if(n < 0)   return;
	for(int i = 0; i < 10; i++){ //0~9
		if(n - db[i] >= 0){
			tmp += (i + '0');
			dfs(n - db[i]);
		}else{
		return;
		}
	}
	return;
} 

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int n;
    int t;
    cin >> t;
   for(int i = 1; i <= t; i++){
        cin >> n;
        if(n == 1) cout << -1 << "\n";
        else if(n == 2) cout << 1 << "\n";
        else if(n % 7 == 0){
            for(int i = 1; i <= n/7; i++){
                cout << 8;
            }
            cout << "\n";
        }else if((n - 1) % 7 == 0){
            int x = (n - 1) / 7 - 1;
            cout << 10;
            for(int i = 1; i <= x; i++){
                cout << 8;
            }
            cout << "\n";
        }
        else{
        	ans = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
            tmp = "";
        	dfs(n);
        	cout << ans << "\n";
		}
   }
   return 0;
}